package com.ruoyi.api.daoru;

import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;

import java.util.Arrays;
import java.util.stream.Collectors;

/**
 * @author 寻觅
 * @since 2025-07-03
 */
@Data
public class ImportAddress {
    @ExcelProperty("一级")
    private String yiJi;
    @ExcelProperty("二级")
    private String erJi;
//    1:好好  2：哈哈 3：呵呵
@ExcelProperty(value = "三级", converter = StatusConverter.class)
    private Integer sanJi;

    public enum StatusAddress {
        COMPLETED(1, "好好"),
        PAYING_SIGNING(2, "哈哈"),
        SIGNING_PAYING(3, "呵呵");


        private final int code;
        private final String text;

        StatusAddress(int code, String text) {
            this.code = code;
            this.text = text;
        }

        // 根据文字查找对应的数字代码
        public static Integer getCodeByText(String text) {
            if (text == null) return null;
            for (ImportAddress.StatusAddress status : values()) {
                if (status.text.equals(text.trim())) {
                    return status.code;
                }
            }
            return null; // 未找到匹配的状态
        }

        // 验证状态是否有效
        public static boolean isValidCode(Integer code) {
            if (code == null) return false;
            for (ImportAddress.StatusAddress status : values()) {
                if (status.code == code) {
                    return true;
                }
            }
            return false;
        }

        // 获取所有有效状态文本
        public static String getAllValidTexts() {
            return Arrays.stream(values())
                    .map(s -> s.text)
                    .collect(Collectors.joining("、"));
        }
    }
}
